package com.quark.porent.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.quark.porent.entity.QuarkResult;
import com.quark.porent.entity.User;
import com.quark.porent.service.UserService;
import com.quark.porent.utils.HttpClientUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * @Author LHR
 * Create By 2017/8/24
 */
@Service
public class UserServiceImpl implements UserService {

    @Value("${api_getUserByToken}")
    private String api_getUserByToken;

    @Override
    public User getUserByApi(String token) {
        String jsonStr = HttpClientUtils.doGet(api_getUserByToken + token);
        QuarkResult result = JSONObject.parseObject(jsonStr, QuarkResult.class);
        User user = JSONObject.parseObject(result.getData().toString(), User.class);
        return user;
    }
}
